import time


def timeit(*args , **kwargs):
    print('装饰器参数为:{NAME}'.format(NAME = args))

    def outer(fun):  # 第二层才是接受的函数
        def wrapper(*args, **kwargs):
            s_time = time.time()
            fun(*args, **kwargs)
            e_time = time.time()
            print('函数运行时间为：{TIME}'.format(TIME = e_time - s_time))
        return wrapper

    return outer


@timeit(12)
def test01(arg1):
    time.sleep(5)
    print('参数是：{NAME}'.format(NAME = arg1))


test01('asdf ')




# import time
# def computer_runtime(func):
#     pass
#     def wrapper(*args,**kwargs):
#         #函数开始时间
#         start = time.time()
#         print(start)
#         #调用函数
#         func(*args,**kwargs)
#         #结束时间
#         end = time.time()
#         print(end)
#         print('%s执行了%f 秒'%(func.__name__, end - start))
#
#     #回调装饰器函数
#     return wrapper
#
# #语法糖
# @computer_runtime
# #被装饰函数
# def run():
#     #休眠 1 秒
#     time.sleep(1)
#     #推导式
#     ls = [x**2 for x in range(1000)]
#     print(ls)
#
# run()